package cn.iocoder.yudao.module.biz.dal.mysql.staff;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.staff.BizStaffDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.staff.vo.*;

/**
 * 员工 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizStaffMapper extends BaseMapperX<BizStaffDO> {

    default PageResult<BizStaffDO> selectPage(BizStaffPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizStaffDO>()
                .eqIfPresent(BizStaffDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BizStaffDO::getStaffCode, reqVO.getStaffCode())
                .eqIfPresent(BizStaffDO::getSuperStaffCode, reqVO.getSuperStaffCode())
                .likeIfPresent(BizStaffDO::getRealname, reqVO.getRealname())
                .eqIfPresent(BizStaffDO::getPhone, reqVO.getPhone())
                .eqIfPresent(BizStaffDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(BizStaffDO::getSex, reqVO.getSex())
                .eqIfPresent(BizStaffDO::getAge, reqVO.getAge())
                .eqIfPresent(BizStaffDO::getPost, reqVO.getPost())
                .eqIfPresent(BizStaffDO::getStaffDeptId, reqVO.getStaffDeptId())
                .betweenIfPresent(BizStaffDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(BizStaffDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(BizStaffDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizStaffDO::getId));
    }

    default List<BizStaffDO> selectList(BizStaffExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizStaffDO>()
                .eqIfPresent(BizStaffDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BizStaffDO::getStaffCode, reqVO.getStaffCode())
                .eqIfPresent(BizStaffDO::getSuperStaffCode, reqVO.getSuperStaffCode())
                .likeIfPresent(BizStaffDO::getRealname, reqVO.getRealname())
                .eqIfPresent(BizStaffDO::getPhone, reqVO.getPhone())
                .eqIfPresent(BizStaffDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(BizStaffDO::getSex, reqVO.getSex())
                .eqIfPresent(BizStaffDO::getAge, reqVO.getAge())
                .eqIfPresent(BizStaffDO::getPost, reqVO.getPost())
                .eqIfPresent(BizStaffDO::getStaffDeptId, reqVO.getStaffDeptId())
                .betweenIfPresent(BizStaffDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(BizStaffDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(BizStaffDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizStaffDO::getId));
    }

}
